home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
TURB_VIS
/
MISC
/
MISC.DOC
< prev
next >
Wrap
Text File
|
1990-12-17
|
9KB
|
291 lines
MISC.PAS
A Turbo Vision Object Library
By Devin Cook
MSD - 1990
I haven't been exactly overwhelmed by the amount of Turbo Vision objects shared
by TP users, so I thought I would thow my hat into the ring and spread a few
objects I have developed around.
I am not an expert in Turbo Vision ( who can be in 3 weeks? ), or in OOP, so I
have probably broken quite a few rules, but you might get some ideas from the
work I have done.
This unit has some of the my more mainstream objects included. I have a few
other, less general objects which I may spread around later.
These objects have not been used enough to verify they are 100% bug free, so
if you find any problems, or have any comments, please send me some Email
( D.Cook on Genie ).
OBJECTS:
TDateView - A date text box, much like TClockView in TVDemos.
TPushButton - A descendend of TButton, with "feel" for keyboard users.
TNum_Box - A number only input box with an adjustable number of digits
before and after the decimal point, along with selectable
negative number acceptance.
TLinked_Dialog - A descendent of TDialog which allows you to set "Links"
between items ( i.e. item selection through cursor keys ).
Also, FormatDate, a function used by TDateView is provided.
╔═════════════╗
║ TDateView ║
╚═════════════╝
TDateView is almost identicle to TClockView ( in TVDemos - Gadget.Pas ).
INITIALIZATION:
TDateView is initialized by sending TDateView a TRect giving it's location.
USAGE:
Once TDateView is initialized, an occasional call to TDateView.Update keeps
the displayed date current.
Example:
Var TR : TRect ;
DateV : TDateView ;
Begin
TR.Assign( 60 , 0 , 78 , 1 );
DateV.Init( TR );
DateV.Update ;
End;
╔═══════════════╗
║ TPushButton ║
╚═══════════════╝
TPushButton is identicle to TButton in every way except that when it is
"pressed", it actually draws itself pressed.
This gives visual feedback to those using non-mouse systems.
The delay values in TPushButton.Press may need to be altered to adjust the
"feel".
╔════════════╗
║ TNum_Box ║
╚════════════╝
TNum_Box is a numerical entry box with definable precision.
INITIALIZATION:
TNum_Box is initialized by sending TNum_Box.Init:
Location : TPoint
Max Digits before the decimal point : Integer
Max Digits after the decimal point : Integer
Negative Numbers allowed flag : Boolean
Default Value : Extended
If the digits after the decimal point = 0, no decimal point is displayed
( or excepted ).
If negative numbers are allowed, one extra space is reserved for a negative
sign. No digits can be entered in this spot.
Only Backspace is used to edit the numberical field.
USAGE:
The value of the input box can be read directly from TNum_Box.Curr_Val.
This value may not be up to date if editing is still taking place, or no
data has been entered. To ensure a correct reading, a call to
TNum_Box.Update_Value is recommended.
After initilization, the box is displayed with blanks for the number of digits.
If you wish to display the default value instead, use TNum_Box.Update_Value.
Example:
Var TP : TPoint ;
Int_Box1 : TNum_Box ;
Int_Box2 : TNum_Box ;
Flt_Box1 : TNum_Box ;
Begin
Tp.X := 10 ;
Tp.Y := 5 ;
(* Define a box at 10,5 with 3 digits, no decimals, no negatives and a
default of 0 *)
Int_Box1.Init( TP , 3 , 0 , False , 0 )
TP.X := 15 ;
(* Define a box at 10,15 with 5 digits, no decimals, negatives and a
default of 1. Then, update the box displaying the default *)
Int_Box2.Init( TP , 5 , 0 , True , 1 )
Int_Box2.Update_Value ;
TP.X := 25 ;
(* Define a box at 10,25 with 5 digits, 2 decimal places , negatives and
a default of 0. Leave the box a blank. *)
flt_Box1.Init( TP , 5 , 2 , True , 0 )
End;
╔══════════════════╗
║ TLinked_Dialog ║
╚══════════════════╝
TLinked_Dialog is descendant of TDialog with improved cursor movement between
fields.
Developing for a non-mouse system ( even a mouse system ) where your dialogs
have over about 10 fields gets a bit ugly. The tab key becomes impracticle
and setting hotkeys for each field may not be practicle.
The program EXAMPLE.PAS is not an exageration, it is a SIMPLIFIED version of
a dialog I am developing at work. Try getting to a field #54 via tabs!
TLinked_Dialog solves the problem by having the Dialog jump between links
you define. Cursor keys are used to select the link direction, though 2 spare
links are defined for object future use or for object use.
Example of a linking: 11
21 22
31
Object 21 would want links defined for 11 ( DLink_Up ), 22 ( DLink_Right ),
and 31 ( DLink_Down ).
Once the links are defined, HandleEvent switches the focus according to the
cursor keys.
INITIALIZATION:
TDialog is initialized exactly the same as TDialog. ( Refer to the Turbo Vision
manual for details. )
TLinked_Dialog.Init calls TDialog.Init and the initialized a collection of
links to track item linking.
USAGE:
Once TLinked_Dialog is initialized, you insert items into the TLinked_Dialog
just as you would a normal dialog.
After the items are inserted, you set up links.
***** NOTE: Do not set up links for an item before it is inserted! *****
Links are created by calling TLinked_Dialog.Set_Link with
Item to set link for : PView
Direction of link : Integer
Use the constants:
DLink_Up, Dlink_Down, DLink_Right,
DLink_Left, DLink_Spare1, Dlink_Spare2
Pointer to linked item : Pointer
All links are 1 way. If you wish Button55 <--> Button56, you must define
two links, Button55 right to Button56 and Button56 left to Button55. This is
because multiple items may be linked to the same item, which would make finding
the reverse link impossible.
You can select another object via a link by calling TLinked_Dialog.Select_Link
with the link direction. The currently selected object's link will be traced
to the next object ( If possible ).
Example:
Var TR : TRect ;
TP : TPoint ;
TLD : TLinked_Dialog ;
Butt1 : TPushButton ;
Box1 : TNum_Box ;
Box2 : TNum_Box ;
Box3 : TNum_Box ;
Box4 : TNum_Box ;
Begin
TR.Assign( 10 , 1 , 70 , 10 );
TLD.Init( TR ,'Test Linked Dialog');
(* Set up a button and insert it *)
TR.Assign( 5 , 3 , 15 , 5 );
Butt1.Init(TR,'~P~ush',cmOk,bfDefault));
TLD.Insert( Butt1 );
(* Set up box1 and insert it *)
TP.Y := 8 ;
TP.X := 3 ;
Box1.Init( TP , 3 , 2 , FALSE , 1 );
TLD.Insert( Box1 );
(* Set up box2 and insert it *)
TP.X := TP.X + 10 ;
Box2.Init( TP , 3 , 2 , FALSE , 1 );
TLD.Insert( Box2 );
TP.Y := 9 ;
TP.X := 3 ;
(* Set up box3 and insert it *)
Box3.Init( TP , 3 , 2 , FALSE , 1 );
TLD.Insert( Box3 );
TP.X := TP.X + 10 ;
(* Set up box and insert it *)
Box4.Init( TP , 3 , 2 , FALSE , 1 );
TLD.Insert( Box4 );
(* Boxes at [1] [2] *)
(* [3] [4] *)
(* Link Box1 -> Box2 *)
TDL.Set_Link( @BOX1 , DLink_Right , @BOX2 );
(* Link Box1 <- Box2 *)
TDL.Set_Link( @BOX2 , DLink_Left , @BOX1 );
(* Link Box3 -> Box4 *)
TDL.Set_Link( @BOX3 , DLink_Right , @BOX4 );
(* Link Box3 <- Box4 *)
TDL.Set_Link( @BOX4 , DLink_Left , @BOX3 );
(* Link Box1 -> Box3 *)
TDL.Set_Link( @BOX1 , DLink_Down , @BOX3 );
(* Link Box1 <- Box3 *)
TDL.Set_Link( @BOX3 , DLink_Up , @BOX1 );
(* Link Box2 -> Box4 *)
TDL.Set_Link( @BOX2 , DLink_Down , @BOX4 );
(* Link Box2 <- Box4 *)
TDL.Set_Link( @BOX4 , DLink_Up , @BOX2 );
End;